/*******************************************************************************
MPLAB Harmony Application Header File
Company:
Microchip Technology Inc.
File Name:
app.h
Summary:
This header file provides prototypes and definitions for the application.
Description:
This header file provides function prototypes and data type definitions for
the application. Some of these are required by the system (such as the
"APP_Initialize" and "APP_Tasks" prototypes) and some of them are only used
internally by the application (such as the "APP_STATES" definition). Both
are defined here for convenience.
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#ifndef _APP_H
#define _APP_H
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "system_config.h"
#include "system_definitions.h"
// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
/* Application States
Summary:
Application states enumeration
Description:
This enumeration defines the valid application states. These states
determine the behaviour of the application at various times.
*/
typedef enum
{
/* Application pixels put*/
APP_STATE_INIT=0,
APP_STATE_OPEN_HOST_LAYER,
APP_STATE_WAIT_FOR_HOST_ENABLE,
APP_STATE_HOST_ENABLE_DONE,
APP_STATE_WAIT_FOR_DEVICE_ATTACH,
APP_STATE_DEVICE_ATTACHED,
APP_STATE_READ_HID,
APP_STATE_DEVICE_DETACHED,
APP_STATE_CHANGE_DEVICE_PARAMETERS,
APP_USART_STATE_DRIVER_OPEN,
APP_USART_STATE_CHECK_FOR_STRING_TO_SEND,
APP_USART_STATE_DRIVER_WRITE,
APP_STATE_ERROR
} APP_STATES;
typedef struct
{
/* Application last data buffer */
USB_HOST_HID_KEYBOARD_DATA data;
} APP_DATA_LAST_DATA;
// *****************************************************************************
/* Application Data
Summary:
Holds application data
Description:
This structure holds the application's data.
Remarks:
Application strings and buffers are be defined outside this structure.
*/
typedef struct
{
/* USB Application's current state*/
APP_STATES state;
/* USART Application task state */
APP_STATES usartTaskState;
/* Unique handle to USB HID Host Keyboard driver */
USB_HOST_HID_KEYBOARD_HANDLE handle;
/* Unique handle to USART driver */
DRV_HANDLE usartDriverHandle;
/* Number of bytes written by the USART write*/
uint32_t nBytesWritten;
/* Size of the buffer to be written */
uint32_t stringSize;
/* Buffer used for USART writing */
uint8_t string[64];
/* Holds the current offset in the string buffer */
uint16_t currentOffset;
/* Flag used to determine if data is to be written to USART */
bool stringReady;
/* Flag used to select CAPSLOCK sequence */
bool capsLockPressed;
/* Flag used to select SCROLLLOCK sequence */
bool scrollLockPressed;
/* Flag used to select NUMLOCK sequence */
bool numLockPressed;
/* Holds the output Report*/
uint8_t outputReport;
/* Application current data buffer */
USB_HOST_HID_KEYBOARD_DATA data;
/* Application last data buffer */
APP_DATA_LAST_DATA lastData;
} APP_DATA;
// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Routines
// *****************************************************************************
// *****************************************************************************
/* These routines are called by drivers when certain events occur.
*/
// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************
/*******************************************************************************
Function:
void APP_Initialize ( void )
Summary:
MPLAB Harmony Demo application initialization routine
Description:
This routine initializes Harmony Demo application. This function opens
the necessary drivers, initializes the timer and registers the application
callback with the USART driver.
Precondition:
All other system initialization routines should be called before calling
this routine (in "SYS_Initialize").
Parameters:
None.
Returns:
None.
Example:
<code>
APP_Initialize();
</code>
Remarks:
This routine must be called from the SYS_Initialize function.
*/
void APP_Initialize ( void );
/*******************************************************************************
Function:
void APP_Tasks ( void )
Summary:
MPLAB Harmony Demo application tasks function
Description:
This routine is the Harmony Demo application's tasks function. It
defines the application's state machine and core logic.
Precondition:
The system and application initialization ("SYS_Initialize") should be
called before calling this.
Parameters:
None.
Returns:
None.
Example:
<code>
APP_Tasks();
</code>
Remarks:
This routine must be called from SYS_Tasks() routine.
*/
void APP_Tasks ( void );
#endif /* _APP_H */
/*******************************************************************************
End of File
*/